package com.yuw.dz.control;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/AjaxDemoServlet")
public class AjaxDemoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 接收ajax引擎发送的request请求中的客户端数据
        String strUserName = request.getParameter("userName");
        System.out.println("ajax传递的参数为："+strUserName);
        // 使用out对象(PrintWriter)将响应内容，输出给ajax引擎对象
        PrintWriter printWriter = response.getWriter();
        // 发送响应内容到浏览器的ajax引擎
        printWriter.println("okkkkkkkkkkkkkkkkkk");
    }
}
